package br.edu.eseg.brproject.model.action;

import br.edu.eseg.brproject.model.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("solicitacaomudancaList")
public class SolicitacaomudancaList extends EntityQuery<Solicitacaomudanca> {

	private static final String EJBQL = "select solicitacaomudanca from Solicitacaomudanca solicitacaomudanca join solicitacaomudanca.usuario usuario join solicitacaomudanca.projeto projeto join solicitacaomudanca.statusmudanca statusmudanca";

	private static final String[] RESTRICTIONS = {
			"lower(solicitacaomudanca.descricao) like lower(concat(#{solicitacaomudancaList.solicitacaomudanca.descricao},'%'))",
			"lower(solicitacaomudanca.justificativa) like lower(concat(#{solicitacaomudancaList.solicitacaomudanca.justificativa},'%'))",
			"lower(solicitacaomudanca.titulo) like lower(concat(#{solicitacaomudancaList.solicitacaomudanca.titulo},'%'))",
			"lower(usuario.nome) like lower(concat(#{solicitacaomudancaList.solicitacaomudanca.usuario.nome},'%'))",
			"lower(projeto.nome) like lower(concat(#{solicitacaomudancaList.solicitacaomudanca.projeto.nome},'%'))",
			"lower(statusmudanca.nome) like lower(concat(#{solicitacaomudancaList.solicitacaomudanca.statusmudanca.nome},'%'))"};

	private Solicitacaomudanca solicitacaomudanca = new Solicitacaomudanca();

	public SolicitacaomudancaList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		getSolicitacaomudanca().setUsuario(new Usuario());
		getSolicitacaomudanca().setProjeto(new Projeto());
		getSolicitacaomudanca().setStatusmudanca(new Statusmudanca());
		setRestrictionLogicOperator("and");
		setMaxResults(25);
	}

	public Solicitacaomudanca getSolicitacaomudanca() {
		return solicitacaomudanca;
	}
}
